package com.acwing.partition1;

import java.io.*;

public class AC8二维费用的背包问题 {

    private static final int N = 1010, V = 110, M = 110;
    private static int[][] f = new int[V][M];
    private static int[] v1 = new int[N], v2 = new int[N], w = new int[N];
    private static int n, v, m;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt(); v = nextInt(); m = nextInt();
        for (int i = 1; i <= n; i++) {
            v1[i] = nextInt();
            v2[i] = nextInt();
            w[i] = nextInt();
        }
        for (int i = 1; i <= n; i++) {
            for (int a = v; a >= v1[i]; a--) {
                for (int b = m; b >= v2[i]; b--) {
                    f[a][b] = Math.max(f[a][b], f[a - v1[i]][b - v2[i]] + w[i]);
                }
            }
        }
        writer.println(f[v][m]);
        writer.flush();
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
